home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / XLisp-Stat / Functions / newton.lsp < prev    next >
Lisp/Scheme  |  1990-10-11  |  489b  |  17 lines

  1. ; book p.107
  2.  
  3. (defun newton-search (f df guess)
  4.   (flet ((improve (guess)
  5.                   (- guess (/ (funcall f guess) (funcall df guess))))
  6.          (good-enough-p (guess)
  7.                         (< (abs (funcall f guess)) .001)))
  8.   (do ((guess guess (improve guess)))
  9.       ((good-enough-p guess) guess))))
  10.  
  11. (defun make-derivative (f h)
  12.   #'(lambda (x)
  13.       (let ((fx+ (funcall f (+ x h)))
  14.             (fx- (funcall f (- x h)))
  15.             (2h (* 2 h)))
  16.        (/ (- fx+ fx-) 2h))))
  17.